Skip to content

Formatting inconsistent when both <tabs> and <spaces> indentation rules are present #2480

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
priyaa2760 opened this issue May 13, 2025 · 2 comments

Comments

@priyaa2760
Copy link

priyaa2760 commented May 13, 2025

I'm encountering inconsistent formatting behavior when both blocks — one tabs true and another with spaces true — are defined under the Spotless configuration in a Maven project.

Some Java files are formatted, some are skipped, and others show partial formatting. When I remove one of the two blocks, the behavior becomes consistent.
I keep getting this debug log
[DEBUG] Spotless will not format an up-to-date file:

<plugin>
        <groupId>com.diffplug.spotless</groupId>
        <artifactId>spotless-maven-plugin</artifactId>
        <version>2.43.0</version>
        <configuration>
          <java>
            <includes>
              <include>src/main/java/**/*.java</include>
              <include>src/test/java/**/*.java</include>
            </includes>
            <trimTrailingWhitespace/>
            <removeUnusedImports/>
            <indent>
              <tabs>true</tabs>
              <spacesPerTab>2</spacesPerTab>
            </indent>
            <indent>
              <spaces>true</spaces>
              <spacesPerTab>4</spacesPerTab>
            </indent>
            <googleJavaFormat>
              <version>1.17.0</version>
            </googleJavaFormat>
          </java>
          <pom>
            <includes>
              <include>pom.xml</include>
            </includes>
            <sortPom>
              <expandEmptyElements>false</expandEmptyElements>
            </sortPom>
          </pom>
          <markdown>
            <excludes>
              <exclude>**/node/**</exclude>
              <exclude>**/node_modules/**</exclude>
            </excludes>
            <includes>
              <include>**/*.md</include>
            </includes>
            <flexmark/>
          </markdown>
        </configuration>
        <executions>
          <execution>
            <goals>
              <goal>check</goal>
            </goals>
            <phase>validate</phase>
          </execution>
        </executions>
      </plugin>
@nedtwigg
Copy link
Member

Try putting the googleJavaFormat step before the indent steps.

@priyaa2760
Copy link
Author

I've tried the above suggestion, but it still does not work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants